#include"udpServer.hpp"
#include"user.hpp"
int main(int argc, char* argv[])
{
    if (argc != 2) 
    {
        std::cerr << "usage : " << argv[0] << "loclaport" << std::endl;
        die(usage_error);
    }
    // std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);
    LogMudule::ENABLE_CONSOLE_LOG();
    // zdl:: 用户管理模块
    std::shared_ptr<userManager> um = std::make_shared<userManager>();
    // zdl:: 网络管理模块
    std::unique_ptr<udpServer> svr_uptr = std::
    make_unique<udpServer>(port);
    svr_uptr->initServer();

    svr_uptr->registerService([&um](inetAddr &id){
        um->addUser(id);
    }, [&um](int sockfd, const std::string& message){
        um->router(sockfd, message);
    });

    svr_uptr->start();
    return 0;
}